package com.example.qingyiapp.ui.activity.fragment.fragment_AddressUI.address_adapter1;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.example.qingyiapp.R;
import com.example.qingyiapp.ui.activity.fragment.fragment_AddressUI.address_bean.JavaBean_lv;

import java.util.List;

public class adapter_address_lv_rv extends RecyclerView.Adapter<adapter_address_lv_rv.MyViewHolder> {

    List<JavaBean_lv.DataBean.ScenicsBeanX.ScenicsBean> scenics;
    Context context;

    public adapter_address_lv_rv(List<JavaBean_lv.DataBean.ScenicsBeanX.ScenicsBean> scenics, Context context) {
        this.scenics = scenics;
        this.context = context;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        return new MyViewHolder(LayoutInflater.from(context).inflate(R.layout.address_rows_lv,null));
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder myViewHolder, int i) {
//        myViewHolder.simpleDraweeView.setImageURI(scenics.get(i).getScenecover());

        Glide.with(context).load(scenics.get(i).getScenecover()).into(myViewHolder.imageView);

        myViewHolder.name.setText(scenics.get(i).getSname());
        myViewHolder.num.setText(scenics.get(i).getFans_num()+"位驿友关注");

    }

    @Override
    public int getItemCount() {
        return scenics.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder{

//        SimpleDraweeView simpleDraweeView;
        ImageView imageView;
        TextView name;
        TextView num;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            imageView = itemView.findViewById(R.id.rows_imgs);
            name = itemView.findViewById(R.id.rows_name);
            num = itemView.findViewById(R.id.rows_msg);

        }
    }

}
